//
//  StatusRetweetedView.swift
//  SinaWeiBo
//
//  Created by tuyue on 16/3/16.
//  Copyright © 2016年 xueyang.co.ltd. All rights reserved.
//

import UIKit
import SnapKit

class StatusRetweetedView: UIView {
    //数据模型
    var retweetedStatus: Status?{
        didSet{
        retweetedLabel.text = retweetedStatus?.text
        pictureView.imageURLs = retweetedStatus?.imageURLs
        }
    }
    
    //重写构造方法
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    //默认报错
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    //setupUI
    private func setupUI(){
    backgroundColor = UIColor(white: 0.95, alpha: 1)
        addSubview(retweetedLabel)
        addSubview(pictureView)
        
        retweetedLabel.snp_makeConstraints { (make) -> Void in
            make.left.top.equalTo(self).offset(StatusCellMargin)
            make.right.equalTo(self.snp_right).offset(-StatusCellMargin)
        }
        
        pictureView.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedLabel.snp_left)
            make.top.equalTo(retweetedLabel.snp_bottom).offset(StatusCellMargin)
            make.size.equalTo(CGSize(width: 100, height: 100))
        }
        
        //给转发微博的底部添加约束
        self.snp_makeConstraints { (make) -> Void in
            make.bottom.equalTo(pictureView.snp_bottom).offset(StatusCellMargin)
        }
    }
    //懒加载子视图
    private lazy var retweetedLabel:UILabel = UIFactory.factoryLable("哈哈哈哈", fontSize: 14, textColor: UIColor.darkGrayColor(), textAligment: .Left)
    
    //懒加载配图
    private lazy var pictureView:StatusPictureView = StatusPictureView()
}
